package com.cby.widget.sample

import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout;
import androidx.appcompat.app.AppCompatActivity
import com.cby.widget.lib.kotlin.*

/**
 * @description: LayoutDSLActivity
 *
 * @author ChenBaoyang
 * @date 2021/10/2 15:03
 */
class LayoutDSLActivity : AppCompatActivity() {


    private val contentView by lazy {
        LinearLayout {
            id = parent_id.toLayoutId()
            layout_width = match_parent
            layout_height = match_parent
            orientation = vertical

            val title = TextView {
                layout_gravity = gravity_center_horizontal
                layout_width = 200
                layout_height = 40
                gravity = gravity_center
                text = "LayoutDSLActivity Page"
                textSize = 16f
                textColor = "#3F4658"
            }

            Button {
                layout_gravity = gravity_center_horizontal
                layout_width = match_parent
                layout_height = wrap_content
                onClick = {
                    showToast("kotlin layout dsl 的实现")
                    title.text = "kotlin layout dsl 的实现"
                }
                text = "测试"
            }

            ImageView {
                layout_gravity = gravity_center_horizontal
                layout_width = 200
                layout_height = 200
                shape = shape {
                    solid_color = "#8e8e8e"
                    corner_radius = 20
                }
            }
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(contentView)
    }

}